/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.lacibMusic.conversores;

/**
 *
 * @author AlanmLira
 */


import br.com.lacibMusic.entidades.GeneroMusical;
import br.com.lacibMusic.rn.GeneroMusicalRN;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;


@FacesConverter(forClass = GeneroMusical.class)
public class GeneroMusicalConversor implements Converter{
    private final GeneroMusicalRN generoMusicalRN = new GeneroMusicalRN();

    @Override
    public Object getAsObject(FacesContext fc, UIComponent uic, String valor) {
        return generoMusicalRN.obter(new Integer(valor));
    }

    @Override
    public String getAsString(FacesContext fc, UIComponent uic, Object o) {
        GeneroMusical generoMusical = (GeneroMusical) o;
        return generoMusical.getId().toString();
    }
}
